package pers.gxm.interpreter;

import java.util.ArrayList;
import java.util.List;

public class CommandListNode extends Node{

    private List<Node> list = new ArrayList<>();
    @Override
    public void parse(Context context) throws ParseException {
        while(true){
            if(context.currentToken() == null){
                throw new ParseException("Missing 'end'");
            } else if ("end".equals(context.currentToken())) {
                context.skipToken("end");
                break;
            }else{
                CommandNode commandNode = new CommandNode();
                commandNode.parse(context);
                list.add(commandNode);
            }
        }
    }

    public String toString(){
        return list.toString();
    }
}
